Java packages serve two purposes:
- Structure — Packages give a structure to the set of classes of your project. It is a bad practice to put all classes flat into the source
directory of a project without a package structure. A structure helps to mentally break down a project into smaller parts, simplifying readers'
understanding of how components are connected and how they interact.
- Avoiding name clashes — a class part of the default package if no explicit package name is specified. This can easily cause name
collisions when other projects define a class of the same name.
When no package is explicitly specified for the classes in your project, this makes the project harder to understand and may cause name collisions
with other projects. Also, classes located in the default package not be accessed from classes within named packages since Java 1.4.